﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsPlatform.Query.WeChat;
using SportsPlatform.Dto.WeChat;
using SportsPlatform.Base;
using SportsPlatform.WeChat.IWeChat;
using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Filters;
using SportsPlatform.Query.SportBusiness.RegistrationInfo;
using SportsPlatform.WeChat.WeChat;
using Microsoft.AspNetCore.Authorization;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 移动端我的报名查询
    /// </summary>
    [Route("api/[controller]/[action]")]
    [AllowAnonymousAttribute]
    public class WeChatRegistrationController : SportsPlatformControllerBase
    {
        private IRegistrationService _registrationService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="registrationService"></param>
        public WeChatRegistrationController(IRegistrationService registrationService)
        {
            _registrationService = registrationService;
        }

        /// <summary>
        /// 移动端查询我的报名分页获取
        /// </summary>
        /// <param name="registrationInfoListQuery"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagePagingDto<RegistrationInfoPageDto>> GetRegistrationInfoPage([FromBody] RegistrationInfoListQuery registrationInfoListQuery)
        {
            return await _registrationService.GetRegistrationInfoPage(registrationInfoListQuery);
        }

        /// <summary>
        /// 移动端我的报名详情查询
        /// </summary>
        /// <param name="registrationDetailsQuery"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<RegistrationInfoDetailsDto>> GetRegistrationInfoDetails([FromBody] RegistrationDetailsQuery registrationDetailsQuery)
        {
            return await _registrationService.GetRegistrationInfoDetails(registrationDetailsQuery);
        }

        /// <summary>
        /// 移动端增加报名信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> AddOrUpdateWeChatRegistration([FromBody] List<AddWeChatRegistrationQuery> query)
        {
            return await _registrationService.AddOrUpdateWeChatRegistration(query);
        }

        /// <summary>
        /// 通过时间判断是否与比赛时间冲突
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<bool>> GetByTimeIsConflict([FromBody] List<AddWeChatRegistrationISQuery> querys)
        {
            return await _registrationService.GetByTimeIsConflict(querys);
        }
    }
}
